package cn.wolfcode.crm.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.pagehelper.PageInfo;

import cn.wolfcode.crm.domain.Permission;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.IPermissionService;
import cn.wolfcode.crm.util.RequiredPermission;

@Controller
@RequestMapping("/permission")
public class PermissionController {
	@Autowired
	private IPermissionService permissionService;
	
	@RequiredPermission({"加载权限", "permission:reload"})
	@RequestMapping("/reload")
	public String reload() {
		permissionService.reload();
		return "redirect:/permission/list";
	}
	
	@RequiredPermission({"权限列表", "permission:list"})
	@RequestMapping("/list")
	public String list(@ModelAttribute("qo") QueryObject qo, Model model) {
		PageInfo<Permission> pageInfo = permissionService.list(qo);
		
		model.addAttribute("pageInfo", pageInfo);
		return "permission/list";
	}

	/*
	@RequestMapping("/saveOrUpdate")
	public String saveOrUpdate(Permission entity) {
		permissionService.saveOrUpdate(entity);
		return "redirect:/permission/list.do";
	}
	*/
}
